package com.example.park2212.patrol

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.lib_base.mvvm.BaseActivity
import com.example.park2212.R
import com.example.park2212.databinding.ActivityPatrolBinding
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = "/app/patrol/PatrolActivity")
class PatrolActivity : BaseActivity<ActivityPatrolBinding,PatrolViewModel>() {
    lateinit var patrolAdapter: PatrolAdapter
    override fun initView() {
        binding.patrolHead.headerTitle.setText("巡逻管理")
        binding.patrolHead.headerBack.setOnClickListener {
            finish()
        }

        patrolAdapter = PatrolAdapter()
        binding.patrolRv.adapter = patrolAdapter
        binding.patrolRv.layoutManager = LinearLayoutManager(this)

    }

    override fun initData() {
        viewModel.getPatrolSuccess.observe(this){
            patrolAdapter.data.clear()
            patrolAdapter.data.addAll(it)
            patrolAdapter.notifyDataSetChanged()
        }
    }

    override fun onResume() {
        super.onResume()
        viewModel.getPatrol()
    }

}